package cn.sm1234.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.sm1234.dao.BlogMapper;
import cn.sm1234.domain.Blog;
import cn.sm1234.service.BlogService;

@Service
@Transactional
public class BlogServiceImpl implements BlogService {

	@Autowired
	private BlogMapper blogMapper;
	
	public void save(Blog blog) {
		//判断当前blog是否id值，如果有id值，那么是修改操作
		if(blog.getId()!=null){
			blogMapper.update(blog);
		}else{
			blogMapper.save(blog);
		}
	}

	@Override
	public List<Blog> findAll() {
		return blogMapper.findAll();
	}

	@Override
	public Blog findById(Integer id) {
		return blogMapper.findById(id);
	}

	@Override
	public void delete(Integer id) {
		blogMapper.delete(id);
	}

}
